package com.wzy.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wzy.db.model.Person;
import com.wzy.service.PersonService;

@Controller
@RequestMapping("person")
public class PersonController {

	@Autowired
	PersonService personService;
	
	@ResponseBody
	@RequestMapping("findById")
	public Object findById(HttpServletRequest request) {
		String id = request.getParameter("id");
		Person p = personService.findById(Integer.parseInt(id));		
		return p;
	}
	
	@ResponseBody
	@RequestMapping("findByName")
	public Object findByName(HttpServletRequest request) {
		String name = request.getParameter("name");		
		Person p = personService.FindByName(name);
		return p;
	}
	
}
